Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Vary header for resource/files fetch operations #4337

Merged
merged 5 commits into from
Oct 6, 2023

Conversation

olivergrabinski
Copy link
Contributor

Closes #4300
Closes #4299

@olivergrabinski olivergrabinski changed the title Introduce Vary header for resource/files fetch operations Add Vary header for resource/files fetch operations Oct 5, 2023
Comment on lines 194 to 196
private val unauthorizedOrNotFound: PartialFunction[FileRejection, Boolean] = {
case _: AuthorizationFailed | _: FileNotFound => true
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's necessary to do this as in the ResourcesRoutes. Without the rejection on AuthorizationFailed it will inject the Vary header into the errors.

Copy link
Contributor

@imsdu imsdu Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better solution could be to improve the vary directive (as relying on rejection is not great) so as not to rely on respondWithHeaders as it is based on mapResponse:

  def mapResponse(f: HttpResponse => HttpResponse): Directive0 =
    mapRouteResultPF { case RouteResult.Complete(response) => RouteResult.Complete(f(response)) }

We could have something like:

  def mapSuccessResponse(f: HttpResponse => HttpResponse): Directive0 =
    mapRouteResultPF { case RouteResult.Complete(response) if response.status.isSuccess => RouteResult.Complete(f(response)) }

And build the vary directive on top of that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's better yes

@olivergrabinski olivergrabinski marked this pull request as ready for review October 5, 2023 13:58
@@ -110,6 +110,13 @@ trait DeltaDirectives extends UriDirectives {
}
}

/** Injects a `Vary: Accept,Accept-Encoding` into the response */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeltaDirectives is temporarily duplicated :)

@olivergrabinski olivergrabinski merged commit d24ff40 into BlueBrain:master Oct 6, 2023
5 checks passed
@olivergrabinski olivergrabinski deleted the vary-header branch October 6, 2023 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants